package com.digiwin.demo.test;

import com.digiwin.demo.sink.AbstractMongoSinkFunction;
import com.digiwin.demo.vo.VisitVO;
import org.bson.Document;

import java.io.Serializable;

/**
 * @Author yanggld
 * @Date 2019/12/26-14:36
 * @Description
 */
public class MyMongoSinkFunction extends AbstractMongoSinkFunction<VisitVO> {

	public MyMongoSinkFunction(String dbName, String colName) {
		super(dbName, colName);
	}

	@Override
	public void invoke(VisitVO vo, Context context) throws Exception {
		Document doc = new Document();
		doc.append("uid", vo.getUid());
		doc.append("name", vo.getName());
		doc.append("date", vo.getDate());
		doc.append("count", vo.getCount());
		collection.insertOne(doc);
	}
}
